﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SalePartial.Utility;
using System.Data.SqlClient;
using System.Data;
using SalePartial.Model;
using SalePartial.IDAL;

namespace SalePartial.SQLServerDAL
{

    //<DataObjectt(True)> _
    public class XPInquiryEvent : IXPInquiryEvent
    {
        // Methods
        //<DataObjecttMethod(DataObjectMethodType.Delete)> _
        public int Delete(Guid EventID)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("EventID", EventID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventDelete]", parameters, RowsAffected);
        }

        //<DataObjecttMethod(DataObjectMethodType.Delete)> _
        public int DeleteByBuyerCompanyID(Guid BuyerCompanyID)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("BuyerCompanyID", BuyerCompanyID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsDeleteByBuyerCompanyID]", parameters, RowsAffected);
        }

        //<DataObjecttMethod(DataObjectMethodType.Delete)> _
        public int DeleteByInquiryID(Guid InquiryID)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("InquiryID", InquiryID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsDeleteByInquiryID]", parameters, RowsAffected);
        }

        //<DataObjecttMethod(DataObjectMethodType.Delete)> _
        public int DeleteByVendorCompanyID(Guid VendorCompanyID)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("VendorCompanyID", VendorCompanyID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsDeleteByVendorCompanyID]", parameters, RowsAffected);
        }

        //<DataObjecttMethod(DataObjectMethodType.Delete)> _
        public int DeleteDynamic(string v_whereCondition)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("WhereCondition", v_whereCondition) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsDeleteDynamic]", parameters, RowsAffected);
        }

        //<DataObjecttMethod(DataObjectMethodType.Insert)> _
        public int Insert(XPInquiryEventInfo info)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("EventID", info.EventID),
			new SqlParameter("InquiryID", info.InquiryID),
			new SqlParameter("BuyerCompanyID", info.BuyerCompanyID),
			new SqlParameter("QuoteID", info.QuoteID),
			new SqlParameter("VendorCompanyID", info.VendorCompanyID),
			new SqlParameter("EventTime", info.EventTime),
			new SqlParameter("EventType", info.EventType),
			new SqlParameter("EventSequence", info.EventSequence),
			new SqlParameter("EventCode", info.EventCode),
			new SqlParameter("EventMessage", info.EventMessage),
			new SqlParameter("EventStatus", info.EventStatus),
			new SqlParameter("Importance", info.Importance),
			new SqlParameter("IsFlagged", info.IsFlagged),
			new SqlParameter("EventException", info.EventException)
		};
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventInsert]", parameters, RowsAffected);
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public DataSet SelectAll()
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[0];
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectAll]", parameters, "XPInquiryEvent_All");
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public DataSet SelectByBuyerCompanyID(Guid BuyerCompanyID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("BuyerCompanyID", BuyerCompanyID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectByBuyerCompanyID]", parameters, "XPInquiryEvent_ByBuyerCompanyID");
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public DataSet SelectByInquiryID(Guid InquiryID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("InquiryID", InquiryID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectByInquiryID]", parameters, "XPInquiryEvent_ByInquiryID");
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public DataSet SelectByVendorCompanyID(Guid VendorCompanyID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("VendorCompanyID", VendorCompanyID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectByVendorCompanyID]", parameters, "XPInquiryEvent_ByVendorCompanyID");
        }

        //<DataObjecttMethod(DataObjectMethodType.Fill)> _
        public DataSet SelectDynamic(string v_whereCondition, string v_orderByExpression)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("WhereCondition", v_whereCondition),
			new SqlParameter("OrderByExpression", v_orderByExpression)
		};
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectDynamic]", parameters, "XPInquiryEvent_Dynamic");
        }

        //<DataObjecttMethod(DataObjectMethodType.Fill)> _
        public DataSet SelectPaged()
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[0];
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectPaged]", parameters, "XPInquiryEvent_Paged");
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public SqlDataReader SelectReader(Guid EventID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("EventID", EventID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventSelect]", parameters);
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public SqlDataReader SelectReaderByBuyerCompanyID(Guid BuyerCompanyID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("BuyerCompanyID", BuyerCompanyID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectByBuyerCompanyID]", parameters);
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public SqlDataReader SelectReaderByInquiryID(Guid InquiryID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("InquiryID", InquiryID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectByInquiryID]", parameters);
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public SqlDataReader SelectReaderByVendorCompanyID(Guid VendorCompanyID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("VendorCompanyID", VendorCompanyID) };
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventsSelectByVendorCompanyID]", parameters);
        }

        //<DataObjecttMethod(DataObjectMethodType.Select)> _
        public DataSet SelectSingle(Guid EventID)
        {
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] { new SqlParameter("EventID", EventID) };
            DataSet ds = dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventSelect]", parameters, "XPInquiryEvent_Single");
            DataTable dt = ds.Tables["XPInquiryEvent_Single"];
            return ds;
        }

        //<DataObjecttMethod(DataObjectMethodType.Update)> _
        public int Update(XPInquiryEventInfo info)
        {
            int RowsAffected = 0;
            DbObject dbo = new DbObject(GlobalSetting.ConnectionString);
            SqlParameter[] parameters = new SqlParameter[] {
			new SqlParameter("EventID", info.EventID),
			new SqlParameter("InquiryID", info.InquiryID),
			new SqlParameter("BuyerCompanyID", info.BuyerCompanyID),
			new SqlParameter("QuoteID", info.QuoteID),
			new SqlParameter("VendorCompanyID", info.VendorCompanyID),
			new SqlParameter("EventTime", info.EventTime),
			new SqlParameter("EventType", info.EventType),
			new SqlParameter("EventSequence", info.EventSequence),
			new SqlParameter("EventCode", info.EventCode),
			new SqlParameter("EventMessage",info. EventMessage),
			new SqlParameter("EventStatus", info.EventStatus),
			new SqlParameter("Importance", info.Importance),
			new SqlParameter("IsFlagged", info.IsFlagged),
			new SqlParameter("EventException",info. EventException)
		};
            return dbo.RunProcedure("[dbo].[xunpan_XPInquiryEventUpdate]", parameters, RowsAffected);
        }

    }



}
